<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="${pageContext.request.contextPath}/static/lib/layui/css/layui.css" />
<link rel="stylesheet" href="${pageContext.request.contextPath}/static/lib/bootstrap-3.3.7-dist/css/bootstrap.min.css" />
</head>
<body>
	<div class="container">
	<form class="layui-form" id="formId" method="post" onsubmit="return false">
	  <div class="layui-form-item">
	    <label class="layui-form-label">职务</label>
	    <div class="layui-input-block">
	      <input type="text" name="name" lay-verify="required"  autocomplete="off" class="layui-input">
	    </div>
	  </div>
	  <div class="layui-form-item">
	    <label class="layui-form-label">sn</label>
	    <div class="layui-input-block">
	      <input type="text" name="sn" lay-verify="required"  autocomplete="off" class="layui-input">
	    </div>
	  </div>
	  <div class="layui-form-item">
	    <div class="layui-input-block">
	      <button class="layui-btn" onclick="add()" >立即提交</button>
	      <button type="reset" onclick="reset()" class="layui-btn layui-btn-primary">重置</button>
	    </div>
	  </div>
	</form>
	</div>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/lib/layui/layui.js" ></script>
	<script src="<%=request.getContextPath()%>/static/lib/jquery/jquery-1.11.1.js"></script>
	<script src="${pageContext.request.contextPath}/static/lib/layui/layui.js" type="text/javascript" charset="utf-8"></script>
	<script src="<%=request.getContextPath()%>/static/common/mylayer.js"></script>
	<script type="text/javascript">
	layui.use('layer', function(){
		  var layer = layui.layer;
	})
		function add(){
			$.ajax({
				data : $("#formId").serialize(),
				type : "POST",
				dataType : "json",
				url : "${pageContext.request.contextPath}/role/roleAdd.action",
				success : function(resp){
					if(resp.code == 0){
						mylayer.success(resp.msg);
						  //定时一秒后执行
						  var index = parent.layer.getFrameIndex(window.name);
			              setTimeout(function() {
			            	  //关闭当前弹出层
			                  parent.layer.close(index);
			                  //刷新父页面,刷新table
			                  window.parent.location.reload();
			               }, 1000);
					} else {
						mylayer.error(resp.msg);
					}
				}
			})
		}
	</script>
</body>
</html>